{include file="admin@public/header"/}

<link rel="stylesheet" href="/public/static/admin/css/report.css" />
<link rel="stylesheet" href="/public/static/admin/easyui/layui-v2.6.8/css/layui.css">

<style>
	.ui-icon-ellipsis {
		right: 5px;
	}

	#filter-menu .con {
		width: 355px;
	}

	#filter-menu label.tit {
		width: 80px;
	}

	/*.ui-jqgrid tr.jqgrow td {
	white-space: normal !important;
	}
	*/
	.no-query {
		background: url("/public/static/admin/css/img/no_query.png") no-repeat scroll 100px 60px #fff;
		background-position: center;
		border: 1px solid #ddd;
		border-top: none;
		height: 402px;
		margin-right: 0;
	}

	.box-flex {
		overflow: hidden;
		zoom: 1;
	}

	.box-flex .flex {
		float: left;
		width: 33.3%;
	}

	.grid-title {
		font-size: 24px;
		text-align: center;
		clear: none;
	}

	.ui-print .grid-wrap {
		padding: 10px 0 0 30px;
	}

	#conditions-trigger {
		background: url(/public/static/admin/css/img/bg.png) no-repeat;
		border: 0px;
		width: 74px;
		box-shadow: 0px 0px;
	}

	#filter-menu .conditions-trigger>b {
		position: absolute;
		right: 0;
		top: 50%;
		margin-top: -8px;
		width: 16px;
		height: 16px;
		background: url(/public/static/admin/css/img/down.png) 2px 5px no-repeat;
	}

	#filter-menu .conditions-trigger>b.act {
		background: url(/public/static/admin/css/img/up.png) 2px 5px no-repeat;
	}

	#filter-menu .btns {
		position: absolute;
		top: 7px;
		right: 0px;
	}

	.layui-form-checkbox[lay-skin=primary] i {
		padding: 0;
	}

	.layui-form-checked[lay-skin=primary] i {
		border-color: #5dc5e7;
		background-color: #5dc5e7;
		color: #fff;
		padding: 0;
	}

	.layui-form-checkbox[lay-skin=primary]:hover i {
		border-color: #5dc5e7;
	}

	.ui-droplist-wrap {
		height: auto;
	}

	#filterItems {
		height: auto;
	}

	.ui-droplist-wrap .list-item:hover {
		background-color: #faffad;
	}

	.ui-print .ui-jqgrid .ui-jqgrid-hdiv,
	.ui-print .ui-jqgrid .ui-jqgrid-htable th {
		background: url(/public/static/admin/youshang/css/img/ui-th.png) repeat-x #EEE;
	}

	.ui-print .ui-jqgrid .ui-jqgrid-view th,
	.ui-print .ui-jqgrid .ui-jqgrid-view td,
	.ui-print .ui-jqgrid .ui-jqgrid-view div {
		border-color: #dedede;
	}

	.ui-print .ui-jqgrid {
		border-color: #dedede;
	}
</style>

<div class="wrapper">
	<!-- header -->
	<div class="mod-search cf">
		<div class="l  layui-form" id="filter-menu">
			<ul class="ul-inline fix" id="filterItems" style="font-size: 12px;">
				<li style="display: list-item;">
					<input type="text" id="matchCon" class="ui-input con ui-input-ph" value=""
						placeholder="请输入单据号或客户名或备注" style="width: 200px;font-size: 12px;">
				</li>
				<li id="date" style="display: list-item;"><label>日期:</label>
					<input type="date" id="startdate" class="ui-input " value="2021-08-09" style="width: 115px;">
					<span class="todate"> 至 </span>
					<input type="date" id="enddate" class="ui-input " value="2021-08-09" style="width: 115px;">
				</li>

				<!-- 选择仓库 -->
				{include file="admin@select/store"/}

				<li id="store" style="display: list-item;">
					<div class="btns" style="top: 0px;position: relative;float: right;margin-top: 0;margin-left: 15px;">
						<a class="ui-btn mrb ui-btn-search" id="filter-submit">查询</a>
					</div>
				</li>



				<!-- <span class="url-box" id="openUrl"><a href="https://club.kingdee.com/club/newclub/school/course?product_id=7&amp;cid=1548#pid=5713" target="_blank" class="video-icon" style="margin-right: 5px;"></a>功能简介</span> -->
			</ul>
			<!-- <a href="#" id="conditions-trigger" class="ui-btn conditions-trigger" tabindex="-1">&nbsp;更多条件<b></b></a> -->
		</div>


	</div>



	<!-- no data -->
	<!-- <div class="no-query"></div> -->
	<!-- grid begin -->
	<div class="ui-print" id="ui-print">
		<!-- 列配置 -->
		<div class="cf box-flex">
			<div class="flex">
				<span id="config" class="ui-config"><a href="#" class="ui-icon-config-new"></a>列设置</span>
			</div>
			<div class="fr">
				<a class="ui-btn-bill ui-btn-add" id="add"
					onclick="addPage('/store/costadjustment/add.html','storage','成本调整单')">新增</a>
				<a class="ui-btn-bill ui-btn-hl mrb" id="export" target="_blank">导出</a>
				<a href="#" class="ui-btn-bill ui-btn-hl" id="btn-batchDel">删除</a>
			</div>
		</div>

		<div class="grid-wrap" id="grid-wrap" style="padding-bottom: 30px;padding-right: 30px;">
			<table id="grid"></table>
			<div id="page"></div>
		</div>
	</div>
	<!-- grid end -->

	<!--  以隐藏的方式获取商品的样式 ，作用是赋值 -->
	<div style="display:none;">

	</div>
</div>

<script type="text/javascript" src="/public/static/admin/easyui/jeasyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
	function preview(oper) {
		if (oper < 10) {
			$("#grid-wrap").jqprint();
		} else {
			window.print();
		}
	}
</script>


<script type="text/javascript">

	$(document).ready(function () {

		// 点击查询按钮
		$("#filter-submit").click(function () {

			var startdate = $('#startdate').val();
			var enddate = $('#enddate').val();

			//此处可以添加对查询数据的合法验证 
			$("#grid").jqGrid('setGridParam', {
				datatype: 'json',
				postData: { 'ajax': '100' }, //发送数据 
				page: 1
			}).trigger("reloadGrid"); //重新载入 
		});

		//alert("1111");
		$("#grid").jqGrid({
			url: '/store/costadjustment/index.html?ajax=100',
			datatype: "json",//数据来源，本地数据（local，json,jsonp,xml等）
			height: '90%',//高度，表格高度。可为数值、百分比或'auto'
			colNames: ["id", "操作", "单据日期", "单据编号", "业务类别", "金额", "制单人", "备注", "打印次数"],
			colModel: [
				{ name: 'id', width: 60, hidden: true },
				{ name: '', index: 'id', width: 60, label: "操作", formatter: cLink },
				{ name: 'addtime', width: 100, label: "单据日期" },
				{ name: 'sn', width: 120, label: "单据编号" },
				{ name: 'type', width: 150, label: "业务类别" },
				{ name: 'money', width: 100, label: "金额" },
				{ name: 'auth_user', width: 80, label: "制单人" },
				{ name: 'mark', width: 200, label: "备注" },
				{ name: 'print_num', width: 100, label: "打印次数" }

			],
			sortable: true,  //排序

			rowNum: 100,
			rowList: [100, 200, 500],
			sortname: 'id',
			sortorder: "desc",
			pagerpos: "left",//分页位置
			multiselect: true,//自带多选
			pgbuttons: true,//翻页按钮
			pagination: true,
			altRows: !0,
			gridview: !0,
			shrinkToFit: !1,
			cellLayout: 8,
			autowidth: !0,
			pager: "#page",
			viewrecords: !0,
			cmTemplate: {
				sortable: !1,
				title: !1
			},
			loadError: function (t, e, i) {
				parent.Public.tips({
					type: 1,
					content: "操作失败了哦，请检查您的网络链接！"
				})
			},
			//双击表格行事件
			ondblClickRow: function (row) {
				var rowData = $('#grid').jqGrid('getRowData', row);
				parent.tab.addTabItem({
					tabid: "storage",
					text: "成本调整单",
					url: "/store/costadjustment/edit.html?id=" + rowData.id,
				})
			}
		});

	});
	// 操作按钮
	function cLink(cellvalue, options, rowObject) {
		return '<div class="operating"><span class="ui-icon ui-icon-pencil" onclick="" title="修改"></span><span class="ui-icon ui-icon-trash" onclick="del(' + rowObject.id + ')" title="删除"></span></div>'
	}


</script>

<script type="text/javascript">
	$(document).ready(function () {
		// 获取当前日期
		var myDate = new Date;
		var year = myDate.getFullYear(); //获取当前年
		var mon = myDate.getMonth() + 1; //获取当前月
		var date = myDate.getDate(); //获取当前日
		// console.log(year + '-' + mon + '-' + date)
		if (mon < 10) {
			mon = "0" + mon;
		}
		if (date < 10) {
			date = "0" + date;
		}
		$("#startdate").val(year + '-' + mon + '-01');
		$("#enddate").val(year + '-' + mon + '-' + date);


		//顶部搜索是否展开（1：展开，0：未展开）
		var headH = 0;
		$("#conditions-trigger").click(function () {
			if (headH == 0) {
				headH = 1;
				$("#filterItems").css({ "height": "auto" });
				$(this).html("&nbsp;收起条件<b class='act'></b>");
			} else {
				headH = 0;
				$("#filterItems").css({ "height": "44px" });
				// $("#filterItems").animate({height:'44px'});
				$(this).html("&nbsp;更多条件<b></b>");
			}
		});

		// 搜索仓库弹窗
		$("#storage").on("click", function () {
			var top = $(this).offset().top;
			var left = $(this).offset().left;
			var width = $(this).width();
			$("#storageBox").toggle();
			$("#storageBox").css({ "top": (top + 24) + "px", "left": (left) + "px", "minWidth": width + "px" });
		});
		// 选择仓库
		$("#storageBox .list-item").on("click", function () {
			$(this).addClass("selected").siblings().removeClass("selected");
			var title = $(this).attr("title");
			var val = $(this).attr("data-value");
			$("#storageTitle").val(title);
			$("#storageBox").hide();
		});

		// 点击下拉框其他位置隐藏
		$(document).click(function () {
			$("#storageBox").hide();
			$("#categoryBox").hide();
		});
		// 阻止冒泡
		$("#category,#storage").click(function (event) {
			event.stopPropagation();
		});
	});
	$("#filter-submit").click(function () {
		var matchCon = $("#matchCon").val();
		var startdate = $("#startdate").val();
		var enddate = $("#enddate").val(); 
		var store_id = $("#store_id").val();
		$("#grid").jqGrid('setGridParam', {
	        datatype: 'json',
	        postData: {
	        	'search':'1',
	        	'matchCon':matchCon,
	        	'startdate':startdate,
	        	'enddate':enddate,
	        	'store_id':store_id,
	        }, //发送数据 
	        page: 1
	    }).trigger("reloadGrid"); //重新载入
	    var postData = $("#grid").jqGrid("getGridParam", "postData");
　　　　 $.each(postData, function (k, v) { 
　　　　		delete postData[k];  
　　　　 });
	})

</script>

{include file="admin@public/footer"/}